home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // [EN] Adult DVD Empire v0.3
-
- (***************************************************
- * Movie importation script for: *
- * *
- * Adult DVD Empire *
- * http://www.adultdvdempire.com/ *
- * *
- * Based on Twink's ADME script *
- * TwinkMan666@hotmail.com *
- * *
- * Re-written by KaraGarga 10.2004 *
- * karagarga@gmail.com *
- * *
- * For use with Ant Movie Catalog 3.4.0 *
- * www.ant.be.tf/moviecatalog ╖╖╖ www.buypin.com *
- ***************************************************)
-
- program ADE;
-
- const
- ImportSynopsis = True; {into "Description" field}
- ImportADEReview = True; {into "Comments" field}
- ImportCustomerComment = True; {into "Comments" field}
- ImportBigCover = True;
- ImportSmallCover = False;
- ImportRunTime = False;
- ImportDVDDetails =True; {into "Description" field}
- {True = imports related data
- False = NOT import related data}
-
- var
- MovieName: string;
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- function StringReplaceAll(S, Old, New: string): string;
- begin
- while Pos(Old, S) > 0 do
- S := StringReplace(S, Old, New);
- Result := S;
- end;
- procedure CutAfter(var Str: string; Pattern: string);
- begin
- Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str));
- end;
- procedure CutBefore(var Str: string; Pattern: string);
- begin
- Str := Copy(Str, Pos(Pattern, Str), Length(Str));
- end;
-
- function GetStringFromHTML(Page, StartTag, CutTag, EndTag: string): string;
- begin
- Result := '';
- if Pos(StartTag, Page) > 0 then begin
- CutBefore(Page, StartTag);
- if Length(CutTag) > 0 then
- CutAfter(Page, CutTag);
- Result := Copy(Page, 0, Pos(EndTag, Page) - 1);
- HTMLDecode(Result);
- end;
- end;
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- LineNr: Integer;
- Line, Value: String;
- BeginPos, EndPos: Integer;
- begin
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
- if pos('<title>Adult DVD Empire - Search - Titles</title>', Page.Text) = 0 then
- begin
- //SetField(fieldURL, Address);
- AnalyzeMoviePage(Page)
- end else
- begin
- PickTreeClear;
- LineNr := 0;
- if FindLine('searchID=',Page,0)>-1 then
- begin
- PickTreeAdd('Adult DVD Empire Title Search:', '');
- repeat
- repeat
- LineNr := FindLine('searchID=', Page, LineNr+1);
- if LineNr > -1 then
- begin
- AddMoviesTitles(Page, LineNr);
- end;
- until LineNr = -1 ;
- // Check for the link of 'Next Page'
- LineNr := FindLine('><nobr><a href=', Page, LineNr+1);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('><nobr><a href=', Line)+16;
- Delete(Line, 1, BeginPos);
- EndPos := pos('''>', Line);
- Value := copy(Line, 1, EndPos - 1);
- Page.Text := GetPage('http://www.adultdvdempire.com/' + Value);
- end;
- until LineNr = -1;
- end;
-
- if PickTreeExec(Address) then
- AnalyzePage(Address);
- end;
- Page.Free;
- end;
-
- procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
- var
- Line, Line1: string;
- MovieTitle, MovieAddress: string;
- StartPos, StartPos1: Integer;
- begin
-
- Line := Page.GetString(LineNr+1);
- Line1 := Page.GetString(LineNr);
- StartPos := pos('</a>', Line);
- StartPos1 := pos('item_id', Line1);
- if StartPos > 0 then
- begin
- MovieAddress := copy(Line1, StartPos1, pos('">', Line1) - StartPos1);
- StartPos := pos('">', Line) + 2;
- MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
- HTMLDecode(Movietitle);
- if MovieTitle <> 'Add to Wish List' then
- if MovieTitle <> '<b>Add to Order</b>' then
- begin
- setField(fieldURL, 'http://www.adultdvdempire.com/Exec/v1_item.asp?' + MovieAddress);
- PickTreeAdd(MovieTitle, 'http://www.adultdvdempire.com/Exec/v1_item.asp?' + MovieAddress);
- end;
- end;
-
- end;
-
- procedure AnalyzeMoviePage(Page: TStringList);
- var
- Line, Value, Value2, FullValue: string;
- LineNr, ValueInt: Integer;
- BeginPos, EndPos, DirectorPos, BrPos: Integer;
- begin
-
- //--------------------------------------
- //URL
- //--------------------------------------
-
- LineNr := FindLine('v4_wishlist_additem.asp?',Page,0);
- if LineNr >-1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('item_id=', Line);
- Delete(Line, 1, BeginPos);
- EndPos := pos('">', Line);
- Value := copy(Line, 1, EndPos - 1);
- setField(fieldURL,'http://www.adultdvdempire.com/exec/v1_item.asp?i'+Value);
- end;
-
- //---------------------
- //Original Title
- //---------------------
-
- LineNr := FindLine('<title>Adult DVD Empire - ',Page,0);
- if LineNr >-1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('ire -', Line)+5;
- Delete(Line, 1, BeginPos);
- EndPos := pos(' - Adult', Line);
- Value := copy(Line, 1, EndPos - 1);
- setField(fieldOriginalTitle,Value);
- end;
-
-
- //------------------------------------
- // Big Cover (adjust in "const" field)
- //--------------------------------------
-
- if ImportBigCover then
- begin
- LineNr := FindLine('<img src="http://images.dvdempire.com/res/movies/', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('src="', Line) + 4;
- Delete(Line, 1, BeginPos);
- EndPos := pos('.jpg"', Line);
- Value := copy(Line, 1, EndPos - 1);
- GetPicture(Value+'h.jpg', False);
- // False = do not store picture externally ; store it in the catalog file
- end
- else ShowMessage('Sorry Cover not available!');
- end;
-
- //------------------------------------
- // Small Cover (adjust in "const" field)
- //--------------------------------------
-
- if ImportSmallCover then
- begin
- LineNr := FindLine('<img src="http://images.dvdempire.com/res/movies/', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('src="', Line) + 4;
- Delete(Line, 1, BeginPos);
- EndPos := pos('"', Line);
- Value := copy(Line, 1, EndPos - 1);
- GetPicture(Value, False);
- // False = do not store picture externally ; store it in the catalog file
- end
- else ShowMessage('Sorry Cover not available!');
- end;
-
-
- //-----------------------------------------------
- //Actors & Director
- //-----------------------------------------------
-
- LineNr := FindLine('<td class="fontsmall3" valign="top" width="100%" nowrap>',Page,0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr+1);
- BeginPos := pos('ò ', Line)+12;
- Delete(Line, 1, BeginPos);
- FullValue := '';
- Value := '';
- repeat
- BeginPos := pos('sort=2', Line);
- Delete(Line, 1, BeginPos+7);
- BrPos := pos('<br>', Line);
- EndPos := pos('</a>', Line);
- Value := copy(Line, 1, EndPos - 1);
- if pos('Director', copy(Line, 1, BrPos - 1)) <> 0 then
- setField(fieldDirector, Value)
- else
- FullValue := FullValue + Value + #13#10;
-
-
- Delete(Line, 1, BrPos);
- until Line = '';
-
- HTMLDecode(FullValue);
- setField(fieldActors,FullValue);
- end;
-
- //-----------------------------------------------
- //Length
- //-----------------------------------------------
- if ImportRunTime then
- begin
- LineNr := FindLine('Length:',Page,0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- Line := RemoveHTMLCrap(Line);
- BeginPos := pos(':', Line);
- Delete(Line, 1, BeginPos);
- EndPos := pos(#13#10, Line);
- Value := trim(copy(Line, 1, EndPos - 1));
- if Value <> 'N/A' then
- begin
- Value := RemoveHTMLCrap(Value);
- BeginPos := pos(' hrs', Value);
- EndPos := pos(' mins', Value);
- ValueInt := StrToInt(Copy(Value, 1, BeginPos - 1), 0) * 60 + StrToInt(Copy(Value, BeginPos + 5, EndPos - BeginPos - 5), 0);
- Value := IntToStr(ValueInt);
- setField(fieldLength,Value);
- end;
- end;
- end;
-
- //-----------------------------------------------
- //Rating
- //-----------------------------------------------
- LineNr := FindLine('Overall Rating:',Page,0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr+4);
- BeginPos := pos('">', Line)+2;
- Delete(Line, 1, BeginPos - 1);
- EndPos := pos(' out', Line);
- Value := IntToStr(Round((StrToInt(copy(Line,1,1), 0) + StrToInt(Copy(Line, 3, endpos-3), 0)/100)*2));
- SetField(fieldRating, Value);
- end;
-
-
- //-----------------------------------------------
- //Year
- //-----------------------------------------------
- LineNr := FindLine('Production Year:',Page,0);
- Value := '';
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- Line := RemoveHTMLCrap(Line);
- BeginPos := pos(': ', Line);
- if BeginPos > 0 then
- begin
- Delete(Line, 1, BeginPos + 1);
- EndPos := pos(#13#10, Line);
- Value := trim(Copy(Line, 1, EndPos - 1));
- end;
- end;
-
- // If we didn't find a production year, use the release date instead
- if Value = '' then
- begin
- LineNr := FindLine('Release Date:',Page,0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- Line := RemoveHTMLCrap(Line);
- BeginPos := pos('/', Line);
- if BeginPos > 0 then
- begin
- Delete(Line, 1, BeginPos);
- BeginPos := pos('/', Line);
- if BeginPos > 0 then
- begin
- Delete(Line, 1, BeginPos);
- EndPos := pos(#13#10, Line);
- Value := trim(Copy(Line, 1, EndPos - 1));
- end;
- end;
- end;
- end;
-
- if Value <> '' then
- SetField(fieldYear, Value);
-
-
- //-----------------------------------------------
- //Category
- //-----------------------------------------------
- LineNr := FindLine('Rating:<font color="white">i</font>', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := Pos('</font>',Line)+7;
- Value := Copy(Line, BeginPos,8);
- Value:=StringReplace(Value, '<br>', '');
- SetField(fieldCategory, Value);
- end;
-
- //-----------------------------------------------
- // Studio
- //-----------------------------------------------
- LineNr := FindLine('<td class="fontsmall" valign="top" align="left" nowrap>', Page, 0);
- if LineNr > -1 then
- begin
- Value := Page.GetString(LineNr + 1);
- Value:=StringReplace(Value, ' ', '');
- Value:=StringReplace(Value, ' ', '');
- Value:=StringReplace(Value, '<font face="verdana, arial, sans-serif" size="-1" color="#ffffff">i</font>', ' ');
- HTMLDecode(Value);
- HTMLRemoveTags(Value);
- SetField(fieldProducer,Value);
- end;
-
- //-------------------------------------------------------
- // Description
- //-------------------------------------------------------
-
- LineNr := FindLine('<b>Synopsis</b>', Page, 0);
- if LineNr > -1 then
- begin
- Value := Page.GetString(LineNr + 19)+#13#10+Page.GetString(LineNr + 20);
- Value:=StringReplace(Value, ' ', '');
- Value:=StringReplace(Value, '<font face="verdana, arial, sans-serif" size="-1" color="#ffffff">i</font>', ' ');
- Value := StringReplace(Value, #13#10, '');
- Value := StringReplace(Value, ' ', '');
- Value := StringReplace(Value, ' ', '');
- Value := StringReplace(Value, 'à','...');
- Value := StringReplace(Value, '<font color="white">i</font>',' ');
- Value := StringReplace(Value, '<br>',#13#10);
- Value := StringReplace(Value, '<BR>',#13#10);
- Value := StringReplace(Value, '<Br>',#13#10);
- Value := StringReplace(Value, '<bR>',#13#10);
- HTMLDecode(Value);
- HTMLRemoveTags(Value);
- SetField(fieldDescription,Value+#13#10+#13#10);
- end;
-
-
- //-------------------------------------------------------
- // DVD Product Information (into "Description" Field)
- //-------------------------------------------------------
-
- if ImportDVDDetails then
- begin
- LineNr := FindLine('<b>Features:</b><br>', Page, 0);
- if LineNr > -1 then
- begin
- Value := GetField(fieldURL);
- Page.Text := GetPage(Value);
- Value:= GetStringFromHTML(Page.Text, '<b>Features:</b><br>', '<br>', 'Studio:');
- Value := StringReplace(Value, #13#10, '');
- Value := StringReplace(Value, ' ', '');
- Value := StringReplace(Value, ' ', '');
- Value := StringReplace(Value, 'à','...');
- Value := StringReplace(Value, '<font color="white">i</font>',' ');
- Value := StringReplace(Value, '<br>',#13#10);
- Value := StringReplace(Value, '<BR>',#13#10);
- Value := StringReplace(Value, '<Br>',#13#10);
- Value := StringReplace(Value, '<bR>',#13#10);
- HTMLRemoveTags(Value);
- SetField(fieldDescription, GetField(fieldDescription)+'DVD DETAILS:'+#13#10+Value);
- end;
- end;
-
- //-------------------------------------------------------
- // ADE (Adult DVD Empire) Review
- //-------------------------------------------------------
- if ImportADEReview then
- begin
- LineNr := FindLine('Empire Reviews</a>', Page, 0);
- if LineNr > -1 then
- begin
- (*Line := Page.GetString(LineNr-1);
- Value:= GetStringFromHTML(Line, '<a href', '="', '">');
- HTMLDecode(Value); *)
- Value := GetField(fieldURL)+'&tab=1';
- Page.Text := GetPage(Value);
- Value:= GetStringFromHTML(Page.Text, '<td class="fontsmall3" valign="top" width="100%">', '100%">', ' ');
- Value := StringReplace(Value, #13#10, '');
- Value := StringReplace(Value, '<br><br>', #13#10);
- Value := StringReplace(Value, ' ', '');
- Value := StringReplace(Value, ' ', '');
- Value := StringReplace(Value, 'à','...');
- Value := StringReplace(Value, 'ô','"');
- Value := StringReplace(Value, 'ö','"');
- Value := StringReplace(Value, '<BR>',#13#10);
- Value := StringReplace(Value, '<Br>',#13#10);
- Value := StringReplace(Value, '<bR>',#13#10);
- HTMLRemoveTags(Value);
- SetField(fieldComments, 'ADULT DVD EMPIRE REVIEW:'+#13#10+Value+#13#10+#13#10);
- end;
- end;
-
- //-------------------------------------------------------
- // Customer Comments (Only first available comment-fully)
- //-------------------------------------------------------
- if ImportCustomerComment then
- begin
- LineNr := FindLine('Customer Comments</a>', Page, 0);
- if LineNr > -1 then
- begin
- (*Line := Page.GetString(LineNr-1);
- Value:= GetStringFromHTML(Line, '<a href', '="', '">');
- HTMLDecode(Value); *)
- Value := GetField(fieldURL)+'&tab=2';
- Page.Text := GetPage(Value);
- LineNr := FindLine('<b>No Customer Comments.</b>', Page, 0);
- if LineNr < 1 then
- begin
- Value:= GetStringFromHTML(Page.Text, '<td class="fontsmall3" valign="top" width="100%">', '100%">', ' ');
- Value := StringReplace(Value, #13#10, '');
- Value := StringReplace(Value, '<br><br>', #13#10);
- Value := StringReplace(Value, ' ', '');
- Value := StringReplace(Value, '<BR>',#13#10);
- Value := StringReplace(Value, '<Br>',#13#10);
- Value := StringReplace(Value, '<bR>',#13#10);
- HTMLRemoveTags(Value);
- SetField(fieldComments, GetField(fieldComments)+'CUSTOMER COMMENTS:'+#13#10+Value);
- end;
- end;
- end;
-
- DisplayResults;
- end;
-
- // They've inserted some crap to make it harder to parse - like
- // a white 'i' instead of spaces.
- function RemoveHTMLCrap(htmlstring: string): string;
- begin
- result := StringReplace(htmlstring, ' ',' ');
- result := StringReplace(result, '<font color="white">i</font>',' ');
- result := StringReplace(result, '<font face="verdana, arial, sans-serif" size="-1" color="#ffffff">i</font>',' ');
- // Also remove italics, bold and underline tags
- result := StringReplace(result, 'à','...');
- result := StringReplace(result, 'ô','"');
- result := StringReplace(result, 'ö','"');
- result := StringReplace(result, '<i>','');
- result := StringReplace(result, '</i>','');
- result := StringReplace(result, '<u>','');
- result := StringReplace(result, '</u>','');
- result := StringReplace(result, '<b>','');
- result := StringReplace(result, '</b>','');
- result := StringReplace(result, '</B>','');
- result := StringReplace(result, '<B>','');
- result := StringReplace(result, '<BR>','');
- result := StringReplace(result, '</BR>','');
- result := StringReplace(result, '</I>','');
- result := StringReplace(result, '<I>','');
- result := StringReplace(result, 'û','-');
- result := StringReplace(result, 'ô','');
- result := StringReplace(result, 'ö','');
- result := StringReplace(result, '<br>',#13#10);
- result := StringReplace(result, ' ','');
- result := StringReplace(result, #9,' '); // Tab
- end;
-
-
- begin
- if CheckVersion(3,2,1) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then
- MovieName := GetField(fieldTranslatedTitle);
- if Input('Adult Movie Empire Import', 'Enter the title of the movie:', MovieName) then
- begin
- AnalyzePage('http://www.adultdvdempire.com/Exec/v1_search_titles.asp?string='+UrlEncode(MovieName));
- end;
- end else
- ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.2.1)');
- end.
-